package com.nf.health.app.utils;


import com.sun.messaging.jmq.util.BASE64Decoder;
import com.sun.messaging.jmq.util.BASE64Encoder;

import java.io.IOException;

/**
 * Created by Jason on 2016/8/19.
*/
public class Base64Util {

    public static  String  getBaseMsgForByte(byte [] bytes){//Base64加密
        String  ss = new String(bytes);
        LogUtil.e("Base64Util",ss+ ""+ new String(bytes));
        System.out.print(""+"Base64Util"+ new String(bytes));
        String fingerprint = new BASE64Encoder() .encodeBuffer(bytes);
        //fingerprint = fingerprint.replace("\n","");
//        LogUtil.e("yuyahao", ""+ fingerprint);
        return fingerprint;
    }

    /**
     * base64解密
     */
    public static String base64Decoder(String str){
        BASE64Decoder decode=new BASE64Decoder();
        String result="";
        byte[] b;
        try {
            b = decode.decodeBuffer(str);
            result=new String(b);

        } catch (IOException e) {
            e.printStackTrace();
        }

        return result;
    }

    /**
     * base64加密
     */
    public static String base64Encoder(String str){
        BASE64Encoder encode = new BASE64Encoder();
        return encode.encode(str.getBytes());

    }
}
